<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class User_model extends CI_Model {

	function __construct()
	{
		parent::__construct();
    }

	function getDataLogin($username)
	{
	    $query = "SELECT * FROM user WHERE USERNAME='$username' AND LEVEL='6'";

        $query = $this->db->query($query);

        return $query;
	}

    function getViewKontrolData($kodeProdi)
    {
      $query = "SELECT * FROM view_kontrol WHERE KODE_PRODI =".$kodeProdi;
      $query = $this->db->query($query);

      if($query->num_rows()>0){
        $data = $query->row();
        return $data;
      }
      else
        return FALSE;
    }

    function getPassSiku($id, $pwd_lama)
	{
	    //$pwd_lama = md5($pwd_lama);
	    $query = "SELECT * FROM `view_user` where `ID`='$id' and `PASSWORD`='$pwd_lama' and SUB_SYSTEM='SIKU'";
        $query = $this->db->query($query);

        if($query->num_rows()>0){
          $data = $query->num_rows();
        }
        else $data = NULL;
        return $data;
	}

    function updatePassSiku($id, $pwd_baru)
	{
        //$pwd_baru = md5($pwd_baru);
	    $query = "UPDATE user SET `PASSWORD` = '$pwd_baru' WHERE ID = '$id' AND LEVEL='6'";
        $query = $this->db->query($query);
    }

}